﻿(function () {
    var testajax = {
        //pageSize: 10
    };  //頁面參數 初始化

    var messages = {
    };
    testajax.messages = messages;

    $(document).ready(function () {
        writeUI();
    }); // $(document).ready     

    function writeUI() {
        renderCustomerList();
    } //writeUI 顯示頁面資訊

    function renderCustomerList() {
        var custmerList = null;

        $.JTQ.Businessservice.GetAllCustomerList(function (resultData) {
            custmerList = resultData;
        }); // Businessservice.GetAllCustomerList

        if (custmerList == null || custmerList == undefined) {
            return;
        }

        var listTemplate = new StringBuilder(); //樣板
        listTemplate.append("<div>客戶代號：{0}，名稱：{1}。</div> ");

        $.each(custmerList, function (i, customer) {
            var customerId = customer.CustomerId;
            var nameZh = customer.NameZh;

            $("#custmerList").append($.validator.format(listTemplate.toString(), customerId, nameZh));
        });
    } // getPostList 取得並顯示客戶清單

    // 建立全域function。可用於HTML屬性中onclick
    window.writeUI = writeUI;
    window.renderCustomerList = renderCustomerList;

    // 建立全域變數
    window.gTestajax = testajax;
})(window);

